<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>MC-GPU: MC-GPU_v1.3.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MC-GPU
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('MC-GPU__v1_83_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">MC-GPU_v1.3.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="MC-GPU__v1_83_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment"></span>
<a name="l00002"></a>00002 <span class="comment">////////////////////////////////////////////////////////////////////////////////</span>
<a name="l00003"></a>00003 <span class="comment"></span><span class="comment">//</span>
<a name="l00004"></a>00004 <span class="comment">//              ****************************</span>
<a name="l00005"></a>00005 <span class="comment">//              *** MC-GPU , version 1.3 ***</span>
<a name="l00006"></a>00006 <span class="comment">//              ****************************</span>
<a name="l00007"></a>00007 <span class="comment">//                                          </span><span class="comment"></span>
<a name="l00008"></a>00008 <span class="comment">//!   Header file containing the declarations for the MC-GPU code.</span>
<a name="l00009"></a>00009 <span class="comment">//!   This file declares all the host and device functions and structures,</span>
<a name="l00010"></a>00010 <span class="comment">//!   the library files to include in the compilation, various constants parameters</span>
<a name="l00011"></a>00011 <span class="comment">//!   of the simulation, pre-processor macro functions, etc.</span>
<a name="l00012"></a>00012 <span class="comment"></span><span class="comment">//</span>
<a name="l00013"></a>00013 <span class="comment">//</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">//          ** DISCLAIMER **</span>
<a name="l00016"></a>00016 <span class="comment">//</span>
<a name="l00017"></a>00017 <span class="comment">// This software and documentation (the &quot;Software&quot;) were developed at the Food and</span>
<a name="l00018"></a>00018 <span class="comment">// Drug Administration (FDA) by employees of the Federal Government in the course</span>
<a name="l00019"></a>00019 <span class="comment">// of their official duties. Pursuant to Title 17, Section 105 of the United States</span>
<a name="l00020"></a>00020 <span class="comment">// Code, this work is not subject to copyright protection and is in the public</span>
<a name="l00021"></a>00021 <span class="comment">// domain. Permission is hereby granted, free of charge, to any person obtaining a</span>
<a name="l00022"></a>00022 <span class="comment">// copy of the Software, to deal in the Software without restriction, including</span>
<a name="l00023"></a>00023 <span class="comment">// without limitation the rights to use, copy, modify, merge, publish, distribute,</span>
<a name="l00024"></a>00024 <span class="comment">// sublicense, or sell copies of the Software or derivatives, and to permit persons</span>
<a name="l00025"></a>00025 <span class="comment">// to whom the Software is furnished to do so. FDA assumes no responsibility</span>
<a name="l00026"></a>00026 <span class="comment">// whatsoever for use by other parties of the Software, its source code,</span>
<a name="l00027"></a>00027 <span class="comment">// documentation or compiled executables, and makes no guarantees, expressed or</span>
<a name="l00028"></a>00028 <span class="comment">// implied, about its quality, reliability, or any other characteristic. Further,</span>
<a name="l00029"></a>00029 <span class="comment">// use of this code in no way implies endorsement by the FDA or confers any</span>
<a name="l00030"></a>00030 <span class="comment">// advantage in regulatory decisions.  Although this software can be redistributed</span>
<a name="l00031"></a>00031 <span class="comment">// and/or modified freely, we ask that any derivative works bear some notice that</span>
<a name="l00032"></a>00032 <span class="comment">// they are derived from it, and any modified versions bear some notice that they</span>
<a name="l00033"></a>00033 <span class="comment">// have been modified.</span>
<a name="l00034"></a>00034 <span class="comment">//                                                                            </span>
<a name="l00035"></a>00035 <span class="comment">//</span><span class="comment"></span>
<a name="l00036"></a>00036 <span class="comment">//!                     @file    MC-GPU_v1.3.h</span>
<a name="l00037"></a>00037 <span class="comment">//!                     @author  Andreu Badal (Andreu.Badal-Soler@fda.hhs.gov)</span>
<a name="l00038"></a>00038 <span class="comment">//!                     @date    2012/12/12</span>
<a name="l00039"></a>00039 <span class="comment"></span><span class="comment">//                      Older versions: 2010/05/14</span>
<a name="l00040"></a>00040 <span class="comment">//</span><span class="comment"></span>
<a name="l00041"></a>00041 <span class="comment">////////////////////////////////////////////////////////////////////////////////</span>
<a name="l00042"></a>00042 <span class="comment"></span>
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 <span class="preprocessor">#ifndef MCGPU_H_</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span><span class="preprocessor">#define MCGPU_H_</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span>
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 <span class="comment">// *** To use CUDA, compile with &quot;-DUSING_CUDA&quot; or uncomment the following line:</span>
<a name="l00049"></a>00049 <span class="comment">//#define USING_CUDA</span>
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="comment">// *** To use MPI to simulate multiple CT projections in different GPUs compile with &quot;-DUSING_MPI&quot; or uncomment the following line:</span>
<a name="l00052"></a>00052 <span class="comment">//#define USING_MPI</span>
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="comment"></span>
<a name="l00055"></a>00055 <span class="comment">//! MPI macro: mark commands to be executed only by the master thread (myID==0).</span>
<a name="l00056"></a><a class="code" href="MC-GPU__v1_83_8h.html#a155f8b8dae8b676fc50d93a287c4e6df">00056</a> <span class="comment"></span><span class="preprocessor">#define MASTER_THREAD if(0==myID)</span>
<a name="l00057"></a>00057 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00058"></a>00058 <span class="comment">//! Maximum number of projections allowed in the CT simulation (not limited by the constant memory because stored in global and shared memory):</span>
<a name="l00059"></a><a class="code" href="MC-GPU__v1_83_8h.html#a30b26edf408e1ff6034eb712ab7e173e">00059</a> <span class="comment"></span><span class="preprocessor">#define  MAX_NUM_PROJECTIONS  720</span>
<a name="l00060"></a>00060 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00061"></a>00061 <span class="comment">//! Constants values for the Compton and Rayleigh models:</span>
<a name="l00062"></a><a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15">00062</a> <span class="comment"></span><span class="preprocessor">#define  MAX_MATERIALS      15</span>
<a name="l00063"></a><a class="code" href="MC-GPU__v1_83_8h.html#a7fc9275784608be88cd40ac55f4de283">00063</a> <span class="preprocessor"></span><span class="preprocessor">#define  MAX_SHELLS         30</span>
<a name="l00064"></a><a class="code" href="MC-GPU__v1_83_8h.html#a50e5fe2bed6d3ba8c550beb81e5e40e5">00064</a> <span class="preprocessor"></span><span class="preprocessor">#define  NP_RAYLEIGH       128</span>
<a name="l00065"></a><a class="code" href="MC-GPU__v1_83_8h.html#a6ca3eda8d58b2d848a9d83c17c89a39c">00065</a> <span class="preprocessor"></span><span class="preprocessor">#define  MAX_ENERGYBINS_RAYLEIGH  25005</span>
<a name="l00066"></a>00066 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00067"></a>00067 <span class="comment">//! Maximum number of energy bins in the input x-ray energy spectrum.</span>
<a name="l00068"></a><a class="code" href="MC-GPU__v1_83_8h.html#a5185f8c2c84b828fb1c961f51527709a">00068</a> <span class="comment"></span><span class="preprocessor">#define  MAX_ENERGY_BINS   256</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span>
<a name="l00070"></a>00070 
<a name="l00071"></a><a class="code" href="MC-GPU__v1_83_8h.html#a598a3330b3c21701223ee0ca14316eca">00071</a> <span class="preprocessor">#define  PI      3.14159265358979323846</span>
<a name="l00072"></a><a class="code" href="MC-GPU__v1_83_8h.html#ac5a945020d3528355cda82d383676736">00072</a> <span class="preprocessor"></span><span class="preprocessor">#define  RAD2DEG 180.0/PI</span>
<a name="l00073"></a><a class="code" href="MC-GPU__v1_83_8h.html#af7e8592d0a634bd3642e9fd508ea8022">00073</a> <span class="preprocessor"></span><span class="preprocessor">#define  DEG2RAD PI/180.0</span>
<a name="l00074"></a>00074 <span class="preprocessor"></span>
<a name="l00075"></a>00075 <span class="comment">// Other constants used in the code:</span><span class="comment"></span>
<a name="l00076"></a>00076 <span class="comment">//! Value to scale the deposited energy in the pixels so that it can be stored as a long long integer</span>
<a name="l00077"></a>00077 <span class="comment">//! instead of a double precision float. The integer values have to be used in order to use the</span>
<a name="l00078"></a>00078 <span class="comment">//! atomicAdd function in CUDA.</span>
<a name="l00079"></a><a class="code" href="MC-GPU__v1_83_8h.html#ac0c03cf5e803404f5dc2a42467395a3a">00079</a> <span class="comment"></span><span class="preprocessor">#define SCALE_eV        100.0f</span>
<a name="l00080"></a>00080 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00081"></a>00081 <span class="comment">//! Offset value to make sure the particles are completely inside, or outside, the voxel bounding box.</span>
<a name="l00082"></a>00082 <span class="comment">//! For example, to start a particle track the source may have to translate a particle from the focal spot to the plane Y=0, but </span>
<a name="l00083"></a>00083 <span class="comment">//! in reality the particle will be moved to Y=EPS_SOURCE to make sure it is unmistakenly located inside a voxel.</span>
<a name="l00084"></a>00084 <span class="comment">//! If &quot;EPS_SOURCE&quot; is too small an artifact with weird concentric circular shadows may appear at the center of the simulated image.</span>
<a name="l00085"></a><a class="code" href="MC-GPU__v1_83_8h.html#a4b98b60caf9dba36fca9fe41c3238404">00085</a> <span class="comment"></span><span class="preprocessor">#define EPS_SOURCE      0.000015f      </span>
<a name="l00086"></a>00086 <span class="preprocessor"></span>
<a name="l00087"></a><a class="code" href="MC-GPU__v1_83_8h.html#a0bc5a0759d92c51db359dddd471d6537">00087</a> <span class="preprocessor">#define NEG_EPS_SOURCE -EPS_SOURCE</span>
<a name="l00088"></a><a class="code" href="MC-GPU__v1_83_8h.html#a12c2040f25d8e3a7b9e1c2024c618cb6">00088</a> <span class="preprocessor"></span><span class="preprocessor">#define INF             500000.0f</span>
<a name="l00089"></a><a class="code" href="MC-GPU__v1_83_8h.html#a67d3a72aafcb824f90fee0293c6a29f5">00089</a> <span class="preprocessor"></span><span class="preprocessor">#define INF_minus1      499999.0f</span>
<a name="l00090"></a><a class="code" href="MC-GPU__v1_83_8h.html#a98e3e165debaf418b6b285ff7538d3f3">00090</a> <span class="preprocessor"></span><span class="preprocessor">#define NEG_INF        -500000.0f</span>
<a name="l00091"></a>00091 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00092"></a>00092 <span class="comment">//! Preprocessor macro to calculate maximum and minimum values:</span>
<a name="l00093"></a><a class="code" href="MC-GPU__v1_83_8h.html#a1b7b63b09e6ac252980467701bd80cb7">00093</a> <span class="comment"></span><span class="preprocessor">#define max_value( a, b ) ( ((a) &gt; (b)) ? (a) : (b) )</span>
<a name="l00094"></a><a class="code" href="MC-GPU__v1_83_8h.html#a9fa6cc963655f85859604988fa68a9e2">00094</a> <span class="preprocessor"></span><span class="preprocessor">#define min_value( a, b ) ( ((a) &lt; (b)) ? (a) : (b) )</span>
<a name="l00095"></a>00095 <span class="preprocessor"></span>
<a name="l00096"></a>00096 
<a name="l00097"></a>00097 <span class="comment">// Include standard header files:</span>
<a name="l00098"></a>00098 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00099"></a>00099 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00100"></a>00100 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00101"></a>00101 <span class="preprocessor">#include &lt;math.h&gt;</span>
<a name="l00102"></a>00102 <span class="preprocessor">#include &lt;time.h&gt;</span>
<a name="l00103"></a>00103 
<a name="l00104"></a>00104 <span class="preprocessor">#include &quot;zlib.h&quot;</span>    <span class="comment">// Library used to read gzip material and voxel files (non-compressed files can also be read). Compile with option -lz</span>
<a name="l00105"></a>00105 
<a name="l00106"></a>00106 <span class="comment">// #ifndef _GNU_SOURCE</span>
<a name="l00107"></a>00107 <span class="comment">// This definition may be required to use the &quot;sincos&quot; function from math.h  !!DeBuG!!</span>
<a name="l00108"></a>00108 <span class="comment">// #define _GNU_SOURCE</span>
<a name="l00109"></a>00109 <span class="comment">// #endif</span>
<a name="l00110"></a>00110 
<a name="l00111"></a>00111 
<a name="l00112"></a>00112 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00113"></a>00113 <span class="preprocessor"></span><span class="comment">// Include CUDA functions:</span>
<a name="l00114"></a>00114 
<a name="l00115"></a>00115   <span class="comment">// CUDA runtime</span>
<a name="l00116"></a>00116 <span class="preprocessor">  #include &lt;cuda_runtime.h&gt;</span>
<a name="l00117"></a>00117   <span class="comment">// Helper functions and utilities to work with CUDA</span>
<a name="l00118"></a>00118 <span class="preprocessor">  #include &lt;helper_functions.h&gt;</span>
<a name="l00119"></a>00119 
<a name="l00120"></a>00120    <span class="comment">// !!DEBUG!! CUDA 5.0: USING ONLY CPU TIMERS. Remove:  #include &lt;cutil_inline.h&gt;</span>
<a name="l00121"></a>00121 <span class="preprocessor">  #include &lt;helper_cuda.h&gt;</span>
<a name="l00122"></a>00122 
<a name="l00123"></a>00123 
<a name="l00124"></a>00124 <span class="comment">//   #include &lt;timer.h&gt;  // !!DEBUG!!   Not necessary??</span>
<a name="l00125"></a>00125 
<a name="l00126"></a>00126 <span class="preprocessor">  #include &lt;vector_types.h&gt;</span>
<a name="l00127"></a>00127 
<a name="l00128"></a>00128 <span class="preprocessor">#else</span>
<a name="l00129"></a>00129 <span class="preprocessor"></span>  <span class="comment">// Include the definition of the vector structures (float3, int2...) that are useful in the GPU (multiple values can be read simultaneously from the slow main memory):</span>
<a name="l00130"></a><a class="code" href="MC-GPU__v1_83_8h.html#abc9d1556799792cec3ef347f78ca112a">00130</a>   <span class="keyword">struct </span><a class="code" href="structint2.html">int2</a>  { <span class="keywordtype">int</span> <a class="code" href="structint2.html#a2b4908d6f7ae421393c0ec0233e90551">x</a>, <a class="code" href="structint2.html#a3d7ff3bd7734f8c2f38613a4da5e6c83">y</a>; };         <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structint2.html">int2</a> <a class="code" href="structint2.html">int2</a>;
<a name="l00131"></a><a class="code" href="MC-GPU__v1_83_8h.html#a21d942232c0a6fe2b0e51f8f74d0f397">00131</a>   <span class="keyword">struct </span><a class="code" href="structint3.html">int3</a>  { <span class="keywordtype">int</span> <a class="code" href="structint3.html#a0a4ad50a155a35fa938ce6f16930affa">x</a>, <a class="code" href="structint3.html#a5d95e23491677d61019f0354b16adca9">y</a>, <a class="code" href="structint3.html#a5cd5a3c388fa28814e3496ef07c39360">z</a>; };      <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structint3.html">int3</a> <a class="code" href="structint3.html">int3</a>;
<a name="l00132"></a><a class="code" href="MC-GPU__v1_83_8h.html#ac5ce49099e54cbb6e687df38a6f3fe96">00132</a>   <span class="keyword">struct </span><a class="code" href="structfloat2.html">float2</a> { <span class="keywordtype">float</span> <a class="code" href="structfloat2.html#a0bb68b4a8de04ffea5f7aae53c48a613">x</a>, <a class="code" href="structfloat2.html#a0f1298f22c4ee20a369cd3b9c25b2cc6">y</a>; };      <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structfloat2.html">float2</a> <a class="code" href="structfloat2.html">float2</a>;
<a name="l00133"></a><a class="code" href="MC-GPU__v1_83_8h.html#a79779bd606ab5af52c38e59729245f27">00133</a>   <span class="keyword">struct </span><a class="code" href="structfloat3.html">float3</a> { <span class="keywordtype">float</span> <a class="code" href="structfloat3.html#af621f02abb1c788738fe61ea9807ff9c">x</a>, <a class="code" href="structfloat3.html#aa6147d421a81889971f8c66aa92abf0d">y</a>, <a class="code" href="structfloat3.html#a772dffd42d89f350c5a1b766c4703245">z</a>; };   <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structfloat3.html">float3</a> <a class="code" href="structfloat3.html">float3</a>;
<a name="l00134"></a><a class="code" href="MC-GPU__v1_83_8h.html#afbcf6d6cd6d7417dcd52f4d48a50f2b1">00134</a>   <span class="keyword">struct </span><a class="code" href="structdouble2.html">double2</a> { <span class="keywordtype">double</span> <a class="code" href="structdouble2.html#a9b503609bcf82337e39ac766fe39214c">x</a>, <a class="code" href="structdouble2.html#a7115f6cec9175e255c655238e3478a88">y</a>; };    <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structdouble2.html">double2</a> <a class="code" href="structdouble2.html">double2</a>;
<a name="l00135"></a><a class="code" href="MC-GPU__v1_83_8h.html#ae1bd8b9d018ba3a5d15e2f2146be2c9e">00135</a>   <span class="keyword">struct </span><a class="code" href="structdouble3.html">double3</a> { <span class="keywordtype">double</span> <a class="code" href="structdouble3.html#ad0570a8f409c151da3737b52cd1ee0a7">x</a>, <a class="code" href="structdouble3.html#ab6fe34e5dcee27325269b48655139159">y</a>, <a class="code" href="structdouble3.html#a44d35dc88f287935fe8a767e0b4b8d00">z</a>; }; <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structdouble3.html">double3</a> <a class="code" href="structdouble3.html">double3</a>;
<a name="l00136"></a><a class="code" href="MC-GPU__v1_83_8h.html#a41a7904c7ce29a6b26ea4c034ffc453b">00136</a>   <span class="keyword">struct </span><a class="code" href="structshort3.html">short3</a> { <span class="keywordtype">short</span> <a class="code" href="structshort3.html#a5d5d88cacca4de50a2334be0033a126a">x</a>, <a class="code" href="structshort3.html#a6056b3f7d064291aaf9121575ec83866">y</a>, <a class="code" href="structshort3.html#a803658b690ee5726c60a2b99b99b9143">z</a>; };   <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structshort3.html">short3</a> <a class="code" href="structshort3.html">short3</a>;  
<a name="l00137"></a><a class="code" href="MC-GPU__v1_83_8h.html#a197f1fccb1076eb0f1555b5571130b2b">00137</a>   <span class="keyword">struct </span><a class="code" href="structulonglong2.html">ulonglong2</a> { <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="structulonglong2.html#a0d94e96b26765bf28a1a4b76391b88bb">x</a>, <a class="code" href="structulonglong2.html#a8453eaa1efda22c449296aa2ebcf0c7f">y</a>; }; <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structulonglong2.html">ulonglong2</a> <a class="code" href="structulonglong2.html">ulonglong2</a>;
<a name="l00138"></a>00138 <span class="preprocessor">#endif</span>
<a name="l00139"></a>00139 <span class="preprocessor"></span>  
<a name="l00140"></a>00140 
<a name="l00141"></a>00141 
<a name="l00142"></a>00142 <span class="preprocessor">#ifdef USING_MPI</span>
<a name="l00143"></a>00143 <span class="preprocessor"></span><span class="comment">// Include MPI functions:</span>
<a name="l00144"></a>00144 <span class="preprocessor">  #include &lt;mpi.h&gt;</span>
<a name="l00145"></a>00145 <span class="preprocessor">#endif</span>
<a name="l00146"></a>00146 <span class="preprocessor"></span>
<a name="l00147"></a>00147 
<a name="l00148"></a>00148 
<a name="l00149"></a>00149 <span class="comment">// MC-GPU structure declarations:</span>
<a name="l00150"></a>00150 <span class="comment"></span>
<a name="l00151"></a>00151 <span class="comment">//! Structure storing the data defining the source model (except for the energy spectrum).</span>
<a name="l00152"></a>00152 <span class="comment">//! When a CT is simulated, multiple sources will be stored in an array (one source instance per projection angle).</span>
<a name="l00153"></a><a class="code" href="structsource__struct.html">00153</a> <span class="comment"></span><span class="keyword">struct</span>
<a name="l00154"></a>00154 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00155"></a>00155 <span class="preprocessor"></span>  __align__(16)
<a name="l00156"></a>00156 <span class="preprocessor">#endif</span>
<a name="l00157"></a>00157 <span class="preprocessor"></span><a class="code" href="structsource__struct.html" title="Structure storing the data defining the source model (except for the energy spectrum).">source_struct</a>       <span class="comment">// Define a cone beam x-ray source.</span>
<a name="l00158"></a>00158 {
<a name="l00159"></a><a class="code" href="structsource__struct.html#af0d7a559e56da9df6b01dda2ac95a787">00159</a>   <a class="code" href="structfloat3.html">float3</a> <a class="code" href="structsource__struct.html#af0d7a559e56da9df6b01dda2ac95a787">position</a>,
<a name="l00160"></a>00160          direction;
<a name="l00161"></a><a class="code" href="structsource__struct.html#a0fcd590a93652a70c73fbc8577d36cfb">00161</a>   <span class="keywordtype">float</span> rot_fan[9],      <span class="comment">// Rotation (from axis (0,1,0)) defined by the source direction (needed by the fan beam source; its inverse is used by the detector).</span>
<a name="l00162"></a>00162         cos_theta_low,   <span class="comment">// Angles for the fan beam model (pyramidal source).</span>
<a name="l00163"></a>00163         phi_low,
<a name="l00164"></a>00164         D_cos_theta,
<a name="l00165"></a>00165         D_phi,
<a name="l00166"></a>00166         max_height_at_y1cm;
<a name="l00167"></a>00167 };
<a name="l00168"></a>00168 
<a name="l00169"></a>00169 <span class="comment"></span>
<a name="l00170"></a>00170 <span class="comment">//! Structure storing the source energy spectrum data to be sampled using the Walker aliasing algorithm.</span>
<a name="l00171"></a><a class="code" href="structsource__energy__struct.html">00171</a> <span class="comment"></span><span class="keyword">struct</span>
<a name="l00172"></a>00172 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00173"></a>00173 <span class="preprocessor"></span>  __align__(16)
<a name="l00174"></a>00174 <span class="preprocessor">#endif</span>
<a name="l00175"></a>00175 <span class="preprocessor"></span><a class="code" href="structsource__energy__struct.html" title="Structure storing the source energy spectrum data to be sampled using the Walker aliasing algorithm...">source_energy_struct</a>       <span class="comment">// Define a cone beam x-ray source.</span>
<a name="l00176"></a>00176 {  
<a name="l00177"></a><a class="code" href="structsource__energy__struct.html#a559e19adbc83b2aea219281e14f82bb1">00177</a>   <span class="keywordtype">int</span> <a class="code" href="structsource__energy__struct.html#a559e19adbc83b2aea219281e14f82bb1">num_bins_espc</a>;                     <span class="comment">// Number of bins in the input energy spectrum</span>
<a name="l00178"></a><a class="code" href="structsource__energy__struct.html#a39635503e804b265f76d3a0f7edb2a9f">00178</a>   <span class="keywordtype">float</span> espc[<a class="code" href="MC-GPU__v1_83_8h.html#a5185f8c2c84b828fb1c961f51527709a" title="Maximum number of energy bins in the input x-ray energy spectrum.">MAX_ENERGY_BINS</a>],           <span class="comment">// Energy values of the input x-ray energy spectrum</span>
<a name="l00179"></a>00179         espc_cutoff[<a class="code" href="MC-GPU__v1_83_8h.html#a5185f8c2c84b828fb1c961f51527709a" title="Maximum number of energy bins in the input x-ray energy spectrum.">MAX_ENERGY_BINS</a>];    <span class="comment">// Cutoffs for the Walker aliasing sampling of the spectrum</span>
<a name="l00180"></a><a class="code" href="structsource__energy__struct.html#a8504b5d435cbf4feef2af89c0fd3f829">00180</a>   <span class="keywordtype">short</span> <span class="keywordtype">int</span> espc_alias[<a class="code" href="MC-GPU__v1_83_8h.html#a5185f8c2c84b828fb1c961f51527709a" title="Maximum number of energy bins in the input x-ray energy spectrum.">MAX_ENERGY_BINS</a>]; <span class="comment">// Aliases for the Walker aliasing sampling algorithm (stored as short to save memory)</span>
<a name="l00181"></a>00181 };
<a name="l00182"></a>00182 
<a name="l00183"></a>00183 <span class="comment"></span>
<a name="l00184"></a>00184 <span class="comment">//! Structure storing the data defining the x-ray detector. </span>
<a name="l00185"></a>00185 <span class="comment">//! For a CT, the struct stores for each angle the detector location and the rotations to</span>
<a name="l00186"></a>00186 <span class="comment">//! transport the detector to a plane perpendicular to +Y.</span>
<a name="l00187"></a>00187 <span class="comment">//! To simulate multiple projections, an array of MAX_NUM_PROJECTIONS of instances of this struct have to be defined!  !!DeBuG!! shared</span>
<a name="l00188"></a><a class="code" href="structdetector__struct.html">00188</a> <span class="comment"></span><span class="keyword">struct</span>
<a name="l00189"></a>00189 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00190"></a>00190 <span class="preprocessor"></span>  __align__(16)
<a name="l00191"></a>00191 <span class="preprocessor">#endif</span>
<a name="l00192"></a>00192 <span class="preprocessor"></span><a class="code" href="structdetector__struct.html" title="Structure storing the data defining the x-ray detector.">detector_struct</a>         <span class="comment">// Define a 2D detector plane, located in front of the defined source (centered at the focal spot and perpendicular to the initial direction).</span>
<a name="l00193"></a>00193 {                       <span class="comment">// The radiograohic image will be stored in the global variable &quot;unsigned long long int *image&quot;.</span>
<a name="l00194"></a><a class="code" href="structdetector__struct.html#a781104d94879829947e6c863ee17abb5">00194</a>   <span class="keywordtype">float</span> <a class="code" href="structdetector__struct.html#a781104d94879829947e6c863ee17abb5">sdd</a>;                                <span class="comment">// Store the source-detector distance</span>
<a name="l00195"></a><a class="code" href="structdetector__struct.html#a824e406500b0d8ca59ca96985a599b8b">00195</a>   <a class="code" href="structfloat3.html">float3</a> <a class="code" href="structdetector__struct.html#a824e406500b0d8ca59ca96985a599b8b">corner_min_rotated_to_Y</a>,
<a name="l00196"></a>00196          center;
<a name="l00197"></a><a class="code" href="structdetector__struct.html#a1f67c512205953e75552865ae7a2490a">00197</a>   <span class="keywordtype">float</span> rot_inv[9],    <span class="comment">// Rotation to transport a particle on the detector plane to a frame where the detector is perpendicular to +Y.</span>
<a name="l00198"></a>00198         <a class="code" href="structdetector__struct.html#a1f67c512205953e75552865ae7a2490a">width_X</a>,
<a name="l00199"></a>00199         height_Z,
<a name="l00200"></a>00200         inv_pixel_size_X,
<a name="l00201"></a>00201         inv_pixel_size_Z;
<a name="l00202"></a><a class="code" href="structdetector__struct.html#a1a30e7168cba7eebe918ab39bb408dce">00202</a>   <a class="code" href="structint2.html">int2</a> <a class="code" href="structdetector__struct.html#a1a30e7168cba7eebe918ab39bb408dce">num_pixels</a>;
<a name="l00203"></a><a class="code" href="structdetector__struct.html#ac26d0b66ebf521346d8ba07609340ea6">00203</a>   <span class="keywordtype">int</span> <a class="code" href="structdetector__struct.html#ac26d0b66ebf521346d8ba07609340ea6">total_num_pixels</a>,
<a name="l00204"></a>00204       rotation_flag;    <span class="comment">// Flag &gt;0 if the initial source direction is not (0,1,0); ==0 otherwise (ie, detector perpendicular to +Y axis and rotation not required).</span>
<a name="l00205"></a>00205 };
<a name="l00206"></a>00206 
<a name="l00207"></a>00207 <span class="comment"></span>
<a name="l00208"></a>00208 <span class="comment">//! Structure defining a voxelized box with the back-lower corner at the coordinate origin.</span>
<a name="l00209"></a><a class="code" href="structvoxel__struct.html">00209</a> <span class="comment"></span><span class="keyword">struct</span>
<a name="l00210"></a>00210 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00211"></a>00211 <span class="preprocessor"></span>  __align__(16)
<a name="l00212"></a>00212 <span class="preprocessor">#endif</span>
<a name="l00213"></a>00213 <span class="preprocessor"></span><a class="code" href="structvoxel__struct.html" title="Structure defining a voxelized box with the back-lower corner at the coordinate origin.">voxel_struct</a>        <span class="comment">// Define a voxelized box with the back-lower corner at the coordinate origin.</span>
<a name="l00214"></a>00214 {                                  <span class="comment">// Voxel material and densities are stored in a local variable.</span>
<a name="l00215"></a><a class="code" href="structvoxel__struct.html#adeed35f7e44a7cfb2891001a1a68f868">00215</a>   <a class="code" href="structint3.html">int3</a> <a class="code" href="structvoxel__struct.html#adeed35f7e44a7cfb2891001a1a68f868">num_voxels</a>;
<a name="l00216"></a><a class="code" href="structvoxel__struct.html#abdd12181cdff77da8b880eedf1d81e33">00216</a>   <a class="code" href="structfloat3.html">float3</a> inv_voxel_size,
<a name="l00217"></a>00217          <a class="code" href="structvoxel__struct.html#abdd12181cdff77da8b880eedf1d81e33">size_bbox</a>;
<a name="l00218"></a>00218 };
<a name="l00219"></a>00219 
<a name="l00220"></a>00220 <span class="comment"></span>
<a name="l00221"></a>00221 <span class="comment">//! Structure with the basic data required by the linear interpolation of the mean free paths: number of values and energy grid.</span>
<a name="l00222"></a><a class="code" href="structlinear__interp.html">00222</a> <span class="comment"></span><span class="keyword">struct</span>
<a name="l00223"></a>00223 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00224"></a>00224 <span class="preprocessor"></span>  __align__(16)
<a name="l00225"></a>00225 <span class="preprocessor">#endif</span>
<a name="l00226"></a>00226 <span class="preprocessor"></span><a class="code" href="structlinear__interp.html" title="Structure with the basic data required by the linear interpolation of the mean free paths: number of ...">linear_interp</a>       <span class="comment">// Constant data for linear interpolation of mean free paths</span>
<a name="l00227"></a>00227 {                                        <span class="comment">// The parameters &#39;a&#39; and &#39;b&#39; are stored in local variables float4 *a, *b;</span>
<a name="l00228"></a><a class="code" href="structlinear__interp.html#a2bea2f84374be1b9afd5d896b16a7a46">00228</a>   <span class="keywordtype">int</span> <a class="code" href="structlinear__interp.html#a2bea2f84374be1b9afd5d896b16a7a46">num_values</a>;      <span class="comment">// --&gt;  Number of iterpolation points (eg, 2^12 = 4096).</span>
<a name="l00229"></a><a class="code" href="structlinear__interp.html#a4b743ecf01ca7d075cc6b36b9ce2f0a1">00229</a>   <span class="keywordtype">float</span> e0,            <span class="comment">// --&gt; Minimum energy</span>
<a name="l00230"></a>00230         <a class="code" href="structlinear__interp.html#a4b743ecf01ca7d075cc6b36b9ce2f0a1">ide</a>;           <span class="comment">// --&gt; Inverse of the energy bin width</span>
<a name="l00231"></a>00231 };
<a name="l00232"></a>00232 
<a name="l00233"></a>00233 <span class="comment"></span>
<a name="l00234"></a>00234 <span class="comment">//! Structure storing the data of the Compton interaction sampling model (equivalent to PENELOPE&#39;s common block /CGCO/).</span>
<a name="l00235"></a><a class="code" href="structcompton__struct.html">00235</a> <span class="comment"></span><span class="keyword">struct</span>
<a name="l00236"></a>00236 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00237"></a>00237 <span class="preprocessor"></span>  __align__(16)
<a name="l00238"></a>00238 <span class="preprocessor">#endif</span>
<a name="l00239"></a>00239 <span class="preprocessor"></span><a class="code" href="structcompton__struct.html" title="Structure storing the data of the Compton interaction sampling model (equivalent to PENELOPE&#39;s common...">compton_struct</a>      <span class="comment">// Data from PENELOPE&#39;s common block CGCO: Compton interaction data</span>
<a name="l00240"></a>00240 {
<a name="l00241"></a><a class="code" href="structcompton__struct.html#a32dcebc4af75e0620abed9c32ffc2bdd">00241</a>   <span class="keywordtype">float</span> fco[<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>*<a class="code" href="MC-GPU__v1_83_8h.html#a7fc9275784608be88cd40ac55f4de283">MAX_SHELLS</a>],
<a name="l00242"></a>00242         uico[<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>*<a class="code" href="MC-GPU__v1_83_8h.html#a7fc9275784608be88cd40ac55f4de283">MAX_SHELLS</a>],
<a name="l00243"></a>00243         fj0[<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>*<a class="code" href="MC-GPU__v1_83_8h.html#a7fc9275784608be88cd40ac55f4de283">MAX_SHELLS</a>];
<a name="l00244"></a><a class="code" href="structcompton__struct.html#aef81eb007c90d13552ea867912f0d2c3">00244</a>   <span class="keywordtype">int</span> noscco[<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>];
<a name="l00245"></a>00245 };
<a name="l00246"></a>00246 <span class="comment"></span>
<a name="l00247"></a>00247 <span class="comment">//! Structure storing the data of the Rayleigh interaction sampling model (equivalent to PENELOPE&#39;s common block /CGRA/).</span>
<a name="l00248"></a><a class="code" href="structrayleigh__struct.html">00248</a> <span class="comment"></span><span class="keyword">struct</span>
<a name="l00249"></a>00249 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00250"></a>00250 <span class="preprocessor"></span>  __align__(16)
<a name="l00251"></a>00251 <span class="preprocessor">#endif</span>
<a name="l00252"></a>00252 <span class="preprocessor"></span><a class="code" href="structrayleigh__struct.html" title="Structure storing the data of the Rayleigh interaction sampling model (equivalent to PENELOPE&#39;s commo...">rayleigh_struct</a>
<a name="l00253"></a>00253 {
<a name="l00254"></a><a class="code" href="structrayleigh__struct.html#a3d91ed8dc782c166106093ae028f0dd8">00254</a>   <span class="keywordtype">float</span> xco[<a class="code" href="MC-GPU__v1_83_8h.html#a50e5fe2bed6d3ba8c550beb81e5e40e5">NP_RAYLEIGH</a>*<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>],
<a name="l00255"></a>00255         pco[<a class="code" href="MC-GPU__v1_83_8h.html#a50e5fe2bed6d3ba8c550beb81e5e40e5">NP_RAYLEIGH</a>*<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>],
<a name="l00256"></a>00256         aco[<a class="code" href="MC-GPU__v1_83_8h.html#a50e5fe2bed6d3ba8c550beb81e5e40e5">NP_RAYLEIGH</a>*<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>],
<a name="l00257"></a>00257         bco[<a class="code" href="MC-GPU__v1_83_8h.html#a50e5fe2bed6d3ba8c550beb81e5e40e5">NP_RAYLEIGH</a>*<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>],
<a name="l00258"></a>00258         pmax[<a class="code" href="MC-GPU__v1_83_8h.html#a6ca3eda8d58b2d848a9d83c17c89a39c">MAX_ENERGYBINS_RAYLEIGH</a>*<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>];
<a name="l00259"></a><a class="code" href="structrayleigh__struct.html#af8eb91b5cbbc3bdf6d84e3aa9525946a">00259</a>   <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> itlco[<a class="code" href="MC-GPU__v1_83_8h.html#a50e5fe2bed6d3ba8c550beb81e5e40e5">NP_RAYLEIGH</a>*<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>],
<a name="l00260"></a>00260                 ituco[<a class="code" href="MC-GPU__v1_83_8h.html#a50e5fe2bed6d3ba8c550beb81e5e40e5">NP_RAYLEIGH</a>*<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>];
<a name="l00261"></a>00261 };
<a name="l00262"></a>00262 
<a name="l00263"></a>00263 
<a name="l00264"></a>00264 <span class="comment"></span>
<a name="l00265"></a>00265 <span class="comment">//// *** HOST FUNCTIONS *** ////</span>
<a name="l00266"></a>00266 <span class="comment"></span>
<a name="l00267"></a>00267 <span class="keywordtype">void</span> <a class="code" href="MC-GPU__v1_83_8cu.html#a04125b2129832959744717839c968ebb" title="Read the input file given in the command line and return the significant data.">read_input</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv, <span class="keywordtype">int</span> myID, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span>* total_histories, <span class="keywordtype">int</span>* gpu_id, <span class="keywordtype">int</span>* seed_input, <span class="keywordtype">int</span>* num_threads_per_block, <span class="keywordtype">int</span>* histories_per_thread, <span class="keyword">struct</span> <a class="code" href="structdetector__struct.html" title="Structure storing the data defining the x-ray detector.">detector_struct</a>* detector_data, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span>** image_ptr, <span class="keywordtype">int</span>* image_bytes, <span class="keyword">struct</span> <a class="code" href="structsource__struct.html" title="Structure storing the data defining the source model (except for the energy spectrum).">source_struct</a>* source_data, <span class="keyword">struct</span> <a class="code" href="structsource__energy__struct.html" title="Structure storing the source energy spectrum data to be sampled using the Walker aliasing algorithm...">source_energy_struct</a>* source_energy_data, <span class="keywordtype">char</span>* file_name_voxels, <span class="keywordtype">char</span> file_name_materials[<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>][250], <span class="keywordtype">char</span>* file_name_output, <span class="keywordtype">char</span>* file_name_espc, <span class="keywordtype">int</span>* num_projections, <span class="keywordtype">double</span>* D_angle, <span class="keywordtype">double</span>* angularROI_0, <span class="keywordtype">double</span>* angularROI_1, <span class="keywordtype">double</span>* initial_angle, <a class="code" href="structulonglong2.html">ulonglong2</a>** voxels_Edep_ptr, <span class="keywordtype">int</span>* voxels_Edep_bytes, <span class="keywordtype">char</span>* file_dose_output, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_x_min, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_x_max, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_y_min, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_y_max, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_z_min, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_z_max, <span class="keywordtype">double</span>* SRotAxisD, <span class="keywordtype">double</span>* vertical_translation_per_projection, <span class="keywordtype">int</span>* flag_material_dose);
<a name="l00268"></a>00268 <span class="keywordtype">void</span> <a class="code" href="MC-GPU__v1_83_8cu.html#aed61d205baa31cea69768bbd68c062c6" title="Read the voxel data and allocate the material and density matrix.">load_voxels</a>(<span class="keywordtype">int</span> myID, <span class="keywordtype">char</span>* file_name_voxels, <span class="keywordtype">float</span>* density_max, <span class="keyword">struct</span> <a class="code" href="structvoxel__struct.html" title="Structure defining a voxelized box with the back-lower corner at the coordinate origin.">voxel_struct</a>* voxel_data, <a class="code" href="structfloat2.html">float2</a>** voxel_mat_dens_ptr, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>* voxel_mat_dens_bytes, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_x_max, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_y_max, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_z_max);
<a name="l00269"></a>00269 <span class="keywordtype">void</span> <a class="code" href="MC-GPU__v1_83_8cu.html#a55f3171a6cdb59fc43e65aa19c676d80" title="Read the material input files and set the mean free paths and the &quot;linear_interp&quot; structures...">load_material</a>(<span class="keywordtype">int</span> myID, <span class="keywordtype">char</span> file_name_materials[<a class="code" href="MC-GPU__v1_83_8h.html#a7aa308231ff3dcfd43ac19023e2e6e15" title="Constants values for the Compton and Rayleigh models:">MAX_MATERIALS</a>][250], <span class="keywordtype">float</span>* density_max, <span class="keywordtype">float</span>* density_nominal, <span class="keyword">struct</span> <a class="code" href="structlinear__interp.html" title="Structure with the basic data required by the linear interpolation of the mean free paths: number of ...">linear_interp</a>* mfp_table_data, <a class="code" href="structfloat2.html">float2</a>** mfp_Woodcock_table, <span class="keywordtype">int</span>* mfp_Woodcock_table_bytes, <a class="code" href="structfloat3.html">float3</a>** mfp_table_a_ptr, <a class="code" href="structfloat3.html">float3</a>** mfp_table_b_ptr, <span class="keywordtype">int</span>* mfp_table_bytes, <span class="keyword">struct</span> <a class="code" href="structrayleigh__struct.html" title="Structure storing the data of the Rayleigh interaction sampling model (equivalent to PENELOPE&#39;s commo...">rayleigh_struct</a> *rayleigh_table_ptr, <span class="keyword">struct</span> <a class="code" href="structcompton__struct.html" title="Structure storing the data of the Compton interaction sampling model (equivalent to PENELOPE&#39;s common...">compton_struct</a> *compton_table_ptr);
<a name="l00270"></a>00270 <span class="keywordtype">void</span> <a class="code" href="MC-GPU__v1_83_8cu.html#a96dba25b308814b25fbae71e27617f12" title="Extract a file name from an input text line, trimming the initial blanks, trailing comment (#) and st...">trim_name</a>(<span class="keywordtype">char</span>* input_line, <span class="keywordtype">char</span>* file_name);
<a name="l00271"></a>00271 <span class="keywordtype">char</span>* <a class="code" href="MC-GPU__v1_83_8cu.html#aea168bca1466813e03b649931a4f670f" title="Read a line of text and trim initial blancks and trailing comments (#).">fgets_trimmed</a>(<span class="keywordtype">char</span>* trimmed_line, <span class="keywordtype">int</span> num, FILE* file_ptr);
<a name="l00272"></a>00272 <span class="keywordtype">int</span> <a class="code" href="MC-GPU__v1_83_8cu.html#aa23f71412757b1d0e1d4c00e6b8a0c18" title="Report the tallied image in ASCII and binary form (32-bit floats).">report_image</a>(<span class="keywordtype">char</span>* file_name_output, <span class="keyword">struct</span> <a class="code" href="structdetector__struct.html" title="Structure storing the data defining the x-ray detector.">detector_struct</a>* detector_data, <span class="keyword">struct</span> <a class="code" href="structsource__struct.html" title="Structure storing the data defining the source model (except for the energy spectrum).">source_struct</a>* source_data, <span class="keywordtype">float</span> mean_energy_spectrum, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span>* image, <span class="keywordtype">double</span> time_elapsed, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> total_histories, <span class="keywordtype">int</span> current_projection, <span class="keywordtype">int</span> num_projections, <span class="keywordtype">double</span> D_angle, <span class="keywordtype">double</span> initial_angle, <span class="keywordtype">int</span> myID, <span class="keywordtype">int</span> numprocs);
<a name="l00273"></a>00273 <span class="keywordtype">void</span> <a class="code" href="MC-GPU__v1_83_8cu.html#a5f62e6c0430761bba20f1e546d396a27" title="Sets the CT trajectory: store in memory the source and detector rotations that are needed to calculat...">set_CT_trajectory</a>(<span class="keywordtype">int</span> myID, <span class="keywordtype">int</span> num_projections, <span class="keywordtype">double</span> D_angle, <span class="keywordtype">double</span> angularROI_0, <span class="keywordtype">double</span> angularROI_1, <span class="keywordtype">double</span> SRotAxisD, <span class="keyword">struct</span> <a class="code" href="structsource__struct.html" title="Structure storing the data defining the source model (except for the energy spectrum).">source_struct</a>* source_data, <span class="keyword">struct</span> <a class="code" href="structdetector__struct.html" title="Structure storing the data defining the x-ray detector.">detector_struct</a>* detector_data, <span class="keywordtype">double</span> vertical_translation_per_projection);
<a name="l00274"></a>00274 <span class="keywordtype">int</span> <a class="code" href="MC-GPU__v1_83_8cu.html#aeceeb305fc1d995c4730e0fcedf10d0c" title="Report the total tallied 3D voxel dose deposition for all projections.">report_voxels_dose</a>(<span class="keywordtype">char</span>* file_dose_output, <span class="keywordtype">int</span> num_projections, <span class="keyword">struct</span> <a class="code" href="structvoxel__struct.html" title="Structure defining a voxelized box with the back-lower corner at the coordinate origin.">voxel_struct</a>* voxel_data, <a class="code" href="structfloat2.html">float2</a>* voxel_mat_dens, <a class="code" href="structulonglong2.html">ulonglong2</a>* voxels_Edep, <span class="keywordtype">double</span> time_elapsed_total, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> total_histories, <span class="keywordtype">short</span> <span class="keywordtype">int</span> dose_ROI_x_min, <span class="keywordtype">short</span> <span class="keywordtype">int</span> dose_ROI_x_max, <span class="keywordtype">short</span> <span class="keywordtype">int</span> dose_ROI_y_min, <span class="keywordtype">short</span> <span class="keywordtype">int</span> dose_ROI_y_max, <span class="keywordtype">short</span> <span class="keywordtype">int</span> dose_ROI_z_min, <span class="keywordtype">short</span> <span class="keywordtype">int</span> dose_ROI_z_max, <span class="keyword">struct</span> <a class="code" href="structsource__struct.html" title="Structure storing the data defining the source model (except for the energy spectrum).">source_struct</a>* source_data);
<a name="l00275"></a>00275 <span class="keywordtype">void</span> <a class="code" href="MC-GPU__v1_83_8cu.html#ac1d6abb26890276f529eed6b7ceafe89" title="Read the energy spectrum file and initialize the Walker aliasing sampling.">init_energy_spectrum</a>(<span class="keywordtype">char</span>* file_name_espc, <span class="keyword">struct</span> <a class="code" href="structsource__energy__struct.html" title="Structure storing the source energy spectrum data to be sampled using the Walker aliasing algorithm...">source_energy_struct</a>* source_energy_data, <span class="keywordtype">float</span> *mean_energy_spectrum);
<a name="l00276"></a>00276 <span class="keywordtype">void</span> <a class="code" href="MC-GPU__v1_83_8cu.html#a6577c51b64b94b13c4e95df776275b5a" title="Initialize the first seed of the pseudo-random number generator (PRNG) RANECU to a position far away ...">update_seed_PRNG</a>(<span class="keywordtype">int</span> batch_number, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> total_histories, <span class="keywordtype">int</span>* seed);
<a name="l00277"></a>00277 <span class="keywordtype">void</span> <a class="code" href="MC-GPU__v1_83_8cu.html#ac2eacae33c0451f6a23fdf1101c6ca11" title="Initialisation of Walker&#39;s aliasing algorithm for random sampling from discrete probability distribut...">IRND0</a>(<span class="keywordtype">float</span> *W, <span class="keywordtype">float</span> *F, <span class="keywordtype">short</span> <span class="keywordtype">int</span> *K, <span class="keywordtype">int</span> N);
<a name="l00278"></a>00278 <span class="keywordtype">int</span> <a class="code" href="MC-GPU__v1_83_8cu.html#aa02ffc836f2b6f9de5386cadb11e30b7" title="Report the tallied dose to each material number, accounting for different densities in different regi...">report_materials_dose</a>(<span class="keywordtype">int</span> num_projections, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> total_histories, <span class="keywordtype">float</span> *density_nominal, <a class="code" href="structulonglong2.html">ulonglong2</a> *materials_dose, <span class="keywordtype">double</span> *mass_materials);
<a name="l00279"></a>00279 
<a name="l00280"></a>00280 
<a name="l00281"></a>00281 <span class="comment">// #ifdef USING_CUDA</span>
<a name="l00282"></a>00282 <span class="comment">//   __host__ __device__     // Enable this code to be able to call the function from the host (CPU) and also from the device (GPU).</span>
<a name="l00283"></a>00283 <span class="comment">// #endif</span>
<a name="l00284"></a>00284 <span class="keywordtype">int</span> <a class="code" href="MC-GPU__v1_83_8cu.html#a0b858ab906084d4426bfe5b522074e2c" title="Finds the interval (x(i),x(i+1)] containing the input value using Walker&#39;s aliasing method...">seeki_walker</a>(<span class="keywordtype">float</span> *cutoff, <span class="keywordtype">short</span> <span class="keywordtype">int</span> *alias, <span class="keywordtype">float</span> randno, <span class="keywordtype">int</span> n);   <span class="comment">// (This function is not actually called in the code.)</span>
<a name="l00285"></a>00285 
<a name="l00286"></a>00286 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00287"></a>00287 <span class="preprocessor"></span><span class="keywordtype">int</span> guestimate_GPU_performance(<span class="keywordtype">int</span> gpu_id);
<a name="l00288"></a>00288 <span class="keywordtype">void</span> init_CUDA_device( <span class="keywordtype">int</span>* gpu_id, <span class="keywordtype">int</span> myID, <span class="keywordtype">int</span> numprocs,
<a name="l00289"></a>00289       <span class="comment">/*Variables to GPU constant memory:*/</span> <span class="keyword">struct</span> <a class="code" href="structvoxel__struct.html" title="Structure defining a voxelized box with the back-lower corner at the coordinate origin.">voxel_struct</a>* voxel_data, <span class="keyword">struct</span> <a class="code" href="structsource__struct.html" title="Structure storing the data defining the source model (except for the energy spectrum).">source_struct</a>* source_data, <span class="keyword">struct</span> <a class="code" href="structsource__energy__struct.html" title="Structure storing the source energy spectrum data to be sampled using the Walker aliasing algorithm...">source_energy_struct</a>* source_energy_data, <span class="keyword">struct</span> <a class="code" href="structdetector__struct.html" title="Structure storing the data defining the x-ray detector.">detector_struct</a>* detector_data, <span class="keyword">struct</span> <a class="code" href="structlinear__interp.html" title="Structure with the basic data required by the linear interpolation of the mean free paths: number of ...">linear_interp</a>* mfp_table_data,
<a name="l00290"></a>00290       <span class="comment">/*Variables to GPU global memory:*/</span> <a class="code" href="structfloat2.html">float2</a>* voxel_mat_dens, <a class="code" href="structfloat2.html">float2</a>** voxel_mat_dens_device, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> voxel_mat_dens_bytes,
<a name="l00291"></a>00291         <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span>* image, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span>** image_device, <span class="keywordtype">int</span> image_bytes,
<a name="l00292"></a>00292         <a class="code" href="structfloat2.html">float2</a>* mfp_Woodcock_table, <a class="code" href="structfloat2.html">float2</a>** mfp_Woodcock_table_device, <span class="keywordtype">int</span> mfp_Woodcock_table_bytes,
<a name="l00293"></a>00293         <a class="code" href="structfloat3.html">float3</a>* mfp_table_a, <a class="code" href="structfloat3.html">float3</a>* mfp_table_b, <a class="code" href="structfloat3.html">float3</a>** mfp_table_a_device, <a class="code" href="structfloat3.html">float3</a>** mfp_table_b_device, <span class="keywordtype">int</span> mfp_table_bytes,
<a name="l00294"></a>00294         <span class="keyword">struct</span> <a class="code" href="structrayleigh__struct.html" title="Structure storing the data of the Rayleigh interaction sampling model (equivalent to PENELOPE&#39;s commo...">rayleigh_struct</a>* rayleigh_table, <span class="keyword">struct</span> <a class="code" href="structrayleigh__struct.html" title="Structure storing the data of the Rayleigh interaction sampling model (equivalent to PENELOPE&#39;s commo...">rayleigh_struct</a>** rayleigh_table_device,
<a name="l00295"></a>00295         <span class="keyword">struct</span> <a class="code" href="structcompton__struct.html" title="Structure storing the data of the Compton interaction sampling model (equivalent to PENELOPE&#39;s common...">compton_struct</a>* compton_table, <span class="keyword">struct</span> <a class="code" href="structcompton__struct.html" title="Structure storing the data of the Compton interaction sampling model (equivalent to PENELOPE&#39;s common...">compton_struct</a>** compton_table_device,
<a name="l00296"></a>00296         <span class="keyword">struct</span> <a class="code" href="structdetector__struct.html" title="Structure storing the data defining the x-ray detector.">detector_struct</a>** detector_data_device, <span class="keyword">struct</span> <a class="code" href="structsource__struct.html" title="Structure storing the data defining the source model (except for the energy spectrum).">source_struct</a>** source_data_device,
<a name="l00297"></a>00297         <a class="code" href="structulonglong2.html">ulonglong2</a>* voxels_Edep, <a class="code" href="structulonglong2.html">ulonglong2</a>** voxels_Edep_device, <span class="keywordtype">int</span> voxels_Edep_bytes, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_x_min, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_x_max, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_y_min, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_y_max, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_z_min, <span class="keywordtype">short</span> <span class="keywordtype">int</span>* dose_ROI_z_max,
<a name="l00298"></a>00298         <a class="code" href="structulonglong2.html">ulonglong2</a>* materials_dose, <a class="code" href="structulonglong2.html">ulonglong2</a>** materials_dose_device, <span class="keywordtype">int</span> flag_material_dose, <span class="keywordtype">int</span> num_projections);
<a name="l00299"></a>00299 <span class="preprocessor">#endif</span>
<a name="l00300"></a>00300 <span class="preprocessor"></span>
<a name="l00301"></a>00301 
<a name="l00302"></a>00302 <span class="comment"></span>
<a name="l00303"></a>00303 <span class="comment">//// *** DEVICE CONSTANT MEMORY DECLARATION (~global variables in the GPU) *** ////</span>
<a name="l00304"></a>00304 <span class="comment"></span>
<a name="l00305"></a>00305 <span class="comment">// -- Constant memory (defined as global variables):</span>
<a name="l00306"></a>00306 <span class="comment"></span>
<a name="l00307"></a>00307 <span class="comment">//! Global variable to be stored in the GPU constant memory defining the coordinates of the dose deposition region of interest.</span>
<a name="l00308"></a>00308 <span class="comment"></span><span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00309"></a>00309 <span class="preprocessor"></span>__constant__
<a name="l00310"></a>00310 <span class="preprocessor">#endif</span>
<a name="l00311"></a><a class="code" href="MC-GPU__v1_83_8h.html#a81db18966d58018976252f898cd905d9">00311</a> <span class="preprocessor"></span><span class="keywordtype">short</span> <span class="keywordtype">int</span> <a class="code" href="MC-GPU__v1_83_8h.html#a5d34c13b457e76dec83755628ead56fc" title="Global variable to be stored in the GPU constant memory defining the coordinates of the dose depositi...">dose_ROI_x_min_CONST</a>, <a class="code" href="MC-GPU__v1_83_8h.html#a3c22177ce0c73c17ca8716d997678b61">dose_ROI_x_max_CONST</a>, <a class="code" href="MC-GPU__v1_83_8h.html#ac161c8f74fd460e82e73917b3afff5fc">dose_ROI_y_min_CONST</a>, <a class="code" href="MC-GPU__v1_83_8h.html#ab591ece7d8e024dcc8de71f59bc1cea5">dose_ROI_y_max_CONST</a>, <a class="code" href="MC-GPU__v1_83_8h.html#a81db18966d58018976252f898cd905d9">dose_ROI_z_min_CONST</a>, <a class="code" href="MC-GPU__v1_83_8h.html#aea8fcb598ccc9c18ae601f9c7d936b9d">dose_ROI_z_max_CONST</a>;
<a name="l00312"></a>00312 <span class="comment"></span>
<a name="l00313"></a>00313 <span class="comment">//! Global variable to be stored in the GPU constant memory defining the size of the voxel phantom.</span>
<a name="l00314"></a>00314 <span class="comment"></span><span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00315"></a>00315 <span class="preprocessor"></span>__constant__
<a name="l00316"></a>00316 <span class="preprocessor">#endif</span>
<a name="l00317"></a><a class="code" href="MC-GPU__v1_83_8h.html#a129396d7723d11e10c673c1171773cdc">00317</a> <span class="preprocessor"></span><span class="keyword">struct </span><a class="code" href="structvoxel__struct.html" title="Structure defining a voxelized box with the back-lower corner at the coordinate origin.">voxel_struct</a>    <a class="code" href="MC-GPU__v1_83_8h.html#a129396d7723d11e10c673c1171773cdc" title="Global variable to be stored in the GPU constant memory defining the size of the voxel phantom...">voxel_data_CONST</a>;      <span class="comment">// Define the geometric constants</span>
<a name="l00318"></a>00318 <span class="comment"></span>
<a name="l00319"></a>00319 <span class="comment">//! Global variable to be stored in the GPU constant memory defining the x-ray source.</span>
<a name="l00320"></a>00320 <span class="comment"></span><span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00321"></a>00321 <span class="preprocessor"></span>__constant__
<a name="l00322"></a>00322 <span class="preprocessor">#endif</span>
<a name="l00323"></a><a class="code" href="MC-GPU__v1_83_8h.html#a1b4da9b1f73994c4ed1aa7aafd036428">00323</a> <span class="preprocessor"></span><span class="keyword">struct </span><a class="code" href="structsource__struct.html" title="Structure storing the data defining the source model (except for the energy spectrum).">source_struct</a>   <a class="code" href="MC-GPU__v1_83_8h.html#a1b4da9b1f73994c4ed1aa7aafd036428" title="Global variable to be stored in the GPU constant memory defining the x-ray source.">source_data_CONST</a>;     <span class="comment">// Define a particles source.</span>
<a name="l00324"></a>00324 <span class="comment"></span>
<a name="l00325"></a>00325 <span class="comment">//! Global variable to be stored in the GPU constant memory defining the x-ray detector.</span>
<a name="l00326"></a>00326 <span class="comment"></span><span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00327"></a>00327 <span class="preprocessor"></span>__constant__
<a name="l00328"></a>00328 <span class="preprocessor">#endif</span>
<a name="l00329"></a><a class="code" href="MC-GPU__v1_83_8h.html#aea632931ac52bff8d7c9e9cb4e63fd7a">00329</a> <span class="preprocessor"></span><span class="keyword">struct </span><a class="code" href="structdetector__struct.html" title="Structure storing the data defining the x-ray detector.">detector_struct</a> <a class="code" href="MC-GPU__v1_83_8h.html#aea632931ac52bff8d7c9e9cb4e63fd7a" title="Global variable to be stored in the GPU constant memory defining the x-ray detector.">detector_data_CONST</a>;   <span class="comment">// Define a detector layer perpendicular to the y axis</span>
<a name="l00330"></a>00330 <span class="comment"></span>
<a name="l00331"></a>00331 <span class="comment">//! Global variable to be stored in the GPU constant memory defining the linear interpolation data.</span>
<a name="l00332"></a>00332 <span class="comment"></span><span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00333"></a>00333 <span class="preprocessor"></span>__constant__
<a name="l00334"></a>00334 <span class="preprocessor">#endif</span>
<a name="l00335"></a><a class="code" href="MC-GPU__v1_83_8h.html#a8a3e410fb23d04f8a27d3d71c2381d24">00335</a> <span class="preprocessor"></span><span class="keyword">struct </span><a class="code" href="structlinear__interp.html" title="Structure with the basic data required by the linear interpolation of the mean free paths: number of ...">linear_interp</a>   <a class="code" href="MC-GPU__v1_83_8h.html#a8a3e410fb23d04f8a27d3d71c2381d24" title="Global variable to be stored in the GPU constant memory defining the linear interpolation data...">mfp_table_data_CONST</a>;  <span class="comment">// Define size of interpolation arrays</span>
<a name="l00336"></a>00336 <span class="comment"></span>
<a name="l00337"></a>00337 <span class="comment">//! Global variable to be stored in the GPU constant memory defining the source energy spectrum.</span>
<a name="l00338"></a>00338 <span class="comment"></span><span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00339"></a>00339 <span class="preprocessor"></span>__constant__
<a name="l00340"></a>00340 <span class="preprocessor">#endif</span>
<a name="l00341"></a><a class="code" href="MC-GPU__v1_83_8h.html#ad18b13e5db1d8c7c4acdd9af492d6914">00341</a> <span class="preprocessor"></span><span class="keyword">struct </span><a class="code" href="structsource__energy__struct.html" title="Structure storing the source energy spectrum data to be sampled using the Walker aliasing algorithm...">source_energy_struct</a> <a class="code" href="MC-GPU__v1_83_8h.html#ad18b13e5db1d8c7c4acdd9af492d6914" title="Global variable to be stored in the GPU constant memory defining the source energy spectrum...">source_energy_data_CONST</a>;
<a name="l00342"></a>00342 
<a name="l00343"></a>00343 <span class="comment"></span>
<a name="l00344"></a>00344 <span class="comment">//// *** GLOBAL FUNCTIONS *** ////</span>
<a name="l00345"></a>00345 <span class="comment"></span>
<a name="l00346"></a>00346 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00347"></a>00347 <span class="preprocessor"></span>__global__
<a name="l00348"></a>00348 <span class="keywordtype">void</span> init_image_array_GPU(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span>* image, <span class="keywordtype">int</span> pixels_per_image);
<a name="l00349"></a>00349 __global__
<a name="l00350"></a>00350 <span class="keywordtype">void</span> init_dose_array_GPU(<a class="code" href="structulonglong2.html">ulonglong2</a>* voxels_Edep, <span class="keywordtype">int</span> num_voxels_dose);
<a name="l00351"></a>00351 <span class="preprocessor">#endif</span>
<a name="l00352"></a>00352 <span class="preprocessor"></span>
<a name="l00353"></a>00353 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00354"></a>00354 <span class="preprocessor"></span>__global__
<a name="l00355"></a>00355 <span class="keywordtype">void</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#ab1e2e311c809fe74d093498e53c9c954" title="Initialize the image array, ie, set all pixels to zero Essentially, this function has the same effect...">track_particles</a>(<span class="keywordtype">int</span> histories_per_thread, <span class="keywordtype">int</span> num_p, <span class="keywordtype">int</span> seed_input, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span>* image, <a class="code" href="structulonglong2.html">ulonglong2</a>* voxels_Edep, <a class="code" href="structfloat2.html">float2</a>* voxel_mat_dens, <a class="code" href="structfloat2.html">float2</a>* mfp_Woodcock_table, <a class="code" href="structfloat3.html">float3</a>* mfp_table_a, <a class="code" href="structfloat3.html">float3</a>* mfp_table_b, <span class="keyword">struct</span> <a class="code" href="structrayleigh__struct.html" title="Structure storing the data of the Rayleigh interaction sampling model (equivalent to PENELOPE&#39;s commo...">rayleigh_struct</a>* rayleigh_table, <span class="keyword">struct</span> <a class="code" href="structcompton__struct.html" title="Structure storing the data of the Compton interaction sampling model (equivalent to PENELOPE&#39;s common...">compton_struct</a>* compton_table, <span class="keyword">struct</span> <a class="code" href="structdetector__struct.html" title="Structure storing the data defining the x-ray detector.">detector_struct</a>* detector_data_array, <span class="keyword">struct</span> <a class="code" href="structsource__struct.html" title="Structure storing the data defining the source model (except for the energy spectrum).">source_struct</a>* source_data_array, <a class="code" href="structulonglong2.html">ulonglong2</a>* materials_dose);
<a name="l00356"></a>00356 <span class="preprocessor">#else</span>
<a name="l00357"></a>00357 <span class="preprocessor"></span><span class="keywordtype">void</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#ab1e2e311c809fe74d093498e53c9c954" title="Initialize the image array, ie, set all pixels to zero Essentially, this function has the same effect...">track_particles</a>(<span class="keywordtype">int</span> history_batch, <span class="keywordtype">int</span> histories_per_thread, <span class="keywordtype">int</span> num_p, <span class="keywordtype">int</span> seed_input, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span>* image, <a class="code" href="structulonglong2.html">ulonglong2</a>* voxels_Edep, <a class="code" href="structfloat2.html">float2</a>* voxel_mat_dens, <a class="code" href="structfloat2.html">float2</a>* mfp_Woodcock_table, <a class="code" href="structfloat3.html">float3</a>* mfp_table_a, <a class="code" href="structfloat3.html">float3</a>* mfp_table_b, <span class="keyword">struct</span> <a class="code" href="structrayleigh__struct.html" title="Structure storing the data of the Rayleigh interaction sampling model (equivalent to PENELOPE&#39;s commo...">rayleigh_struct</a>* rayleigh_table, <span class="keyword">struct</span> <a class="code" href="structcompton__struct.html" title="Structure storing the data of the Compton interaction sampling model (equivalent to PENELOPE&#39;s common...">compton_struct</a>* compton_table, <span class="keyword">struct</span> <a class="code" href="structdetector__struct.html" title="Structure storing the data defining the x-ray detector.">detector_struct</a>* detector_data_array, <span class="keyword">struct</span> <a class="code" href="structsource__struct.html" title="Structure storing the data defining the source model (except for the energy spectrum).">source_struct</a>* source_data_array, <a class="code" href="structulonglong2.html">ulonglong2</a>* materials_dose);
<a name="l00358"></a>00358 <span class="preprocessor">#endif</span>
<a name="l00359"></a>00359 <span class="preprocessor"></span>
<a name="l00360"></a>00360 <span class="comment"></span>
<a name="l00361"></a>00361 <span class="comment">//// *** DEVICE FUNCTIONS *** ////</span>
<a name="l00362"></a>00362 <span class="comment"></span>
<a name="l00363"></a>00363 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00364"></a>00364 <span class="preprocessor"></span>__device__
<a name="l00365"></a>00365 <span class="preprocessor">#endif</span>
<a name="l00366"></a>00366 <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#a6807df36f6f2501a9f57ea4fce81b4f2" title="Source that creates primary x rays, according to the defined source model.">source</a>(<a class="code" href="structfloat3.html">float3</a>* position, <a class="code" href="structfloat3.html">float3</a>* direction, <span class="keywordtype">float</span>* energy, <a class="code" href="structint2.html">int2</a>* seed, <span class="keywordtype">int</span>* absvox, <span class="keyword">struct</span> <a class="code" href="structsource__struct.html" title="Structure storing the data defining the source model (except for the energy spectrum).">source_struct</a>* source_data_SHARED, <span class="keyword">struct</span> <a class="code" href="structdetector__struct.html" title="Structure storing the data defining the x-ray detector.">detector_struct</a>* detector_data_SHARED);
<a name="l00367"></a>00367 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00368"></a>00368 <span class="preprocessor"></span>__device__
<a name="l00369"></a>00369 <span class="preprocessor">#endif</span>
<a name="l00370"></a>00370 <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#a047931bac84f3bce50dc13061371e765" title="Functions that moves a particle inside the voxelized geometry bounding box.">move_to_bbox</a>(<a class="code" href="structfloat3.html">float3</a>* position, <a class="code" href="structfloat3.html">float3</a>* direction, <a class="code" href="structfloat3.html">float3</a> size_bbox, <span class="keywordtype">int</span>* intersection_flag);
<a name="l00371"></a>00371 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00372"></a>00372 <span class="preprocessor"></span>__device__
<a name="l00373"></a>00373 <span class="preprocessor">#endif</span>
<a name="l00374"></a>00374 <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#aac14e3b20e073c6b169f2bd5c23da281" title="Tally a radiographic projection image.">tally_image</a>(<span class="keywordtype">float</span>* energy, <a class="code" href="structfloat3.html">float3</a>* position, <a class="code" href="structfloat3.html">float3</a>* direction, <span class="keywordtype">signed</span> <span class="keywordtype">char</span>* scatter_state, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span>* image, <span class="keyword">struct</span> <a class="code" href="structsource__struct.html" title="Structure storing the data defining the source model (except for the energy spectrum).">source_struct</a>* source_data_SHARED, <span class="keyword">struct</span> <a class="code" href="structdetector__struct.html" title="Structure storing the data defining the x-ray detector.">detector_struct</a>* detector_data_SHARED);
<a name="l00375"></a>00375 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00376"></a>00376 <span class="preprocessor"></span>__device__
<a name="l00377"></a>00377 <span class="preprocessor">#endif</span>
<a name="l00378"></a>00378 <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#ae7bd0b93b4d5eedb15822fa0ef622b48" title="Initialize the pseudo-random number generator (PRNG) RANECU to a position far away from the previous ...">init_PRNG</a>(<span class="keywordtype">int</span> history_batch, <span class="keywordtype">int</span> histories_per_thread, <span class="keywordtype">int</span> seed_input, <a class="code" href="structint2.html">int2</a>* seed);
<a name="l00379"></a>00379 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00380"></a>00380 <span class="preprocessor"></span>__host__ __device__
<a name="l00381"></a>00381 <span class="preprocessor">#endif</span>
<a name="l00382"></a>00382 <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#ae9061f4314474bf4415200a5cb115397" title="Calculate &quot;(a1*a2) MOD m&quot; with 32-bit integers and avoiding the possible overflow, using the Russian Peasant approach modulo m and the approximate factoring method, as described in: L&#39;Ecuyer and Cote, ACM Trans.">abMODm</a>(<span class="keywordtype">int</span> m, <span class="keywordtype">int</span> a, <span class="keywordtype">int</span> s);
<a name="l00383"></a>00383 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00384"></a>00384 <span class="preprocessor"></span>__device__
<a name="l00385"></a>00385 <span class="preprocessor">#endif</span>
<a name="l00386"></a>00386 <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">float</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#a3b57f2faa5765ceba5d352641ca72a9f" title="Pseudo-random number generator (PRNG) RANECU returning a float value (single precision version)...">ranecu</a>(<a class="code" href="structint2.html">int2</a>* seed);
<a name="l00387"></a>00387 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00388"></a>00388 <span class="preprocessor"></span>__device__
<a name="l00389"></a>00389 <span class="preprocessor">#endif</span>
<a name="l00390"></a>00390 <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#a74c4894502584f8fb113e04b759a6c55" title="Pseudo-random number generator (PRNG) RANECU returning a double value.">ranecu_double</a>(<a class="code" href="structint2.html">int2</a>* seed);
<a name="l00391"></a>00391 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00392"></a>00392 <span class="preprocessor"></span>__device__
<a name="l00393"></a>00393 <span class="preprocessor">#endif</span>
<a name="l00394"></a>00394 <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#a562dba755f1abdb20b1088d3121f4326" title="Find the voxel that contains the current position.">locate_voxel</a>(<a class="code" href="structfloat3.html">float3</a>* position, <a class="code" href="structshort3.html">short3</a>* voxel_coord);
<a name="l00395"></a>00395 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00396"></a>00396 <span class="preprocessor"></span>__device__
<a name="l00397"></a>00397 <span class="preprocessor">#endif</span>
<a name="l00398"></a>00398 <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#a94ad9ed794eb8fd696e7e357ae391765" title="Rotates a vector; the rotation is specified by giving the polar and azimuthal angles in the &quot;self-fra...">rotate_double</a>(<a class="code" href="structfloat3.html">float3</a>* direction, <span class="keywordtype">double</span> cos_theta, <span class="keywordtype">double</span> phi);
<a name="l00399"></a>00399 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00400"></a>00400 <span class="preprocessor"></span>__device__
<a name="l00401"></a>00401 <span class="preprocessor">#endif</span>
<a name="l00402"></a>00402 <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#a5cafd4ebb3d155746b16ca7d231ecad1" title="Sample a Rayleigh interaction using the sampling algorithm used in PENELOPE 2006.">GRAa</a>(<span class="keywordtype">float</span> *energy, <span class="keywordtype">double</span> *costh_Rayleigh, <span class="keywordtype">int</span> *mat, <span class="keywordtype">float</span> *pmax_current, <a class="code" href="structint2.html">int2</a> *seed, <span class="keyword">struct</span> <a class="code" href="structrayleigh__struct.html" title="Structure storing the data of the Rayleigh interaction sampling model (equivalent to PENELOPE&#39;s commo...">rayleigh_struct</a>* cgra);
<a name="l00403"></a>00403 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00404"></a>00404 <span class="preprocessor"></span>__device__
<a name="l00405"></a>00405 <span class="preprocessor">#endif</span>
<a name="l00406"></a>00406 <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#a6f212862e7fba1553ec9495f05443b2c" title="Random sampling of incoherent (Compton) scattering of photons, using the sampling algorithm from PENE...">GCOa</a>(<span class="keywordtype">float</span> *energy, <span class="keywordtype">double</span> *costh_Compton, <span class="keywordtype">int</span> *mat, <a class="code" href="structint2.html">int2</a> *seed, <span class="keyword">struct</span> <a class="code" href="structcompton__struct.html" title="Structure storing the data of the Compton interaction sampling model (equivalent to PENELOPE&#39;s common...">compton_struct</a>* cgco_SHARED);
<a name="l00407"></a>00407 
<a name="l00408"></a>00408 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00409"></a>00409 <span class="preprocessor"></span>__device__
<a name="l00410"></a>00410 <span class="preprocessor">#endif</span>
<a name="l00411"></a>00411 <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#aac6cb77943874a858ac5a79cbd58f1e7" title="Tally the dose deposited in the voxels.">tally_voxel_energy_deposition</a>(<span class="keywordtype">float</span>* Edep, <a class="code" href="structshort3.html">short3</a>* voxel_coord, <a class="code" href="structulonglong2.html">ulonglong2</a>* dose);
<a name="l00412"></a>00412 
<a name="l00413"></a>00413 <span class="preprocessor">#ifdef USING_CUDA</span>
<a name="l00414"></a>00414 <span class="preprocessor"></span>__device__
<a name="l00415"></a>00415 <span class="preprocessor">#endif</span>
<a name="l00416"></a>00416 <span class="preprocessor"></span><span class="keyword">inline</span> 
<a name="l00417"></a>00417 <span class="keywordtype">void</span> <a class="code" href="MC-GPU__kernel__v1_83_8cu.html#a45a0719009ba55cca7af72f08f1090fb" title="Tally the depose deposited inside each material.">tally_materials_dose</a>(<span class="keywordtype">float</span>* Edep, <span class="keywordtype">int</span>* material, <a class="code" href="structulonglong2.html">ulonglong2</a>* materials_dose);
<a name="l00418"></a>00418 
<a name="l00419"></a>00419 
<a name="l00420"></a>00420 <span class="comment">// -- END OF THE &quot;ifndef MCGPU_H_&quot; statement:</span>
<a name="l00421"></a>00421 <span class="preprocessor">#endif</span>
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="MC-GPU__v1_83_8h.html">MC-GPU_v1.3.h</a>      </li>

    <li class="footer">Generated on Mon Dec 17 2012 13:26:39 for MC-GPU by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
